<?php

/**
 * Review form.
 *
 * @package    lezgro
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class MainReviewForm extends BaseReviewForm
{
  public function configure()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'title'           => new sfWidgetFormInputText(),
      'text'            => new sfWidgetFormTextarea(),
        'reviewer'=>new sfWidgetFormInput()
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'user_profile_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('UserProfile'), 'required' => false)),
      'title'           => new sfValidatorString(array('required' => false)),
      'text'            => new sfValidatorString(),
        'reviewer'            => new sfValidatorString(),
    ));

    $this->widgetSchema->setNameFormat('review[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();
  }
  public function bind(array $taintedValues = null, array $taintedFiles = null) {
       $taintedValues['user_profile_id']=sfContext::getInstance()->getUser()->getUserProfile()->getId();
        return parent::bind($taintedValues, $taintedFiles);
    }
}
